<%@page contentType="text/html" pageEncoding="ISO-8859-1" import="Funcionalidad.*, java.util.*,java.net.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="../Apariencia/Cabecera.jsp"/>
<%

        if (session.getAttribute("loginuser") != null) {
            URLDecoder deco = new URLDecoder();
            int rol = (Integer) session.getAttribute("loginrol");
            if (rol == 1) {

                List<Extra> extra = new ArrayList();
                try {
                    extra = Extras.consultaExtra(1);
                } catch (Exception ex) {
                    out.print(ex.getMessage());
                }%>

<html>
    <head>
        <title>FLOG - Administraci&oacute;n About Us</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    </head>
    <div id="administracion" class="admonBio">
        <body>
            <h1>Administraci&oacute;n About Us</h1>
            <form action="" method="POST">
                <table border="0">
                    <%
                Iterator it = extra.iterator();
                String texto = "";
                while (it.hasNext()) {
                    Extra ex = (Extra) it.next();
                    texto = deco.decode(ex.getTexto(), "ISO-8859-1");
                    %>
                    <tr>
                        <td>
                            <textarea name="texto" rows="20" cols="50"><%= texto %> </textarea>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <i>&Uacute;ltima actulizaci&oacute;n <%= ex.getFecha() %></i>
                        </td>
                    </tr>
                    <% }%>
                </table>
                <table border="0">
                <tr>
                <td>
                    <input type="submit" value="Guardar ahora" name="guardar" />
                </td>
            </form>

            <%
                if (request.getParameter("guardar") != null) {
                    try {
                        Extras.updateExtra(1,request.getParameter("texto"));
            %>
            <h3> Post Modificado con exito</h3>
            <jsp:forward page="../Administracion/Admon.jsp"/>
            <%
                    } catch (Exception e) {
                    }
                }
            %>
            <td>
                <form action= "Admon.jsp" method="POST">
                    <input type="submit" value="Volver" name="Volver" />
                </form>
            </td>
            </tr>
            </table>


        </body>
    </div>
</html>
<%
            } else {
                response.sendRedirect("../Apariencia/VistaPost.jsp");
            }
        }
%>
